package com.zpyr.mvc.controller;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import com.zpyr.common.StringUtil;
import com.zpyr.mvc.vo.Carc_info;


public class CarcMultiCont extends MultiActionController {
	
	private final String viewerRoot = "carc/";
	/*
	public ModelAndView test2(HttpServletRequest req , HttpServletResponse res) {
		ApplicationContext ac = getApplicationContext();
		CarcDao___ dao = ac.getBean(CarcDao___.class);

		
		String info_seq = req.getParameter("info_seq");
		
		Carc_info carc_info = dao.getCarc_info(info_seq);

		ModelAndView mav = new ModelAndView(viewerRoot + "test2");
		mav.addObject("carc_info", carc_info);
		return mav;
	}

	public ModelAndView goCarc_info(HttpServletRequest req , HttpServletResponse res) {
		ApplicationContext ac = getApplicationContext();
		CarcDao___ dao = ac.getBean(CarcDao___.class);

		
		String info_seq = StringUtil.nvl( req.getParameter("info_seq") , "0" );
		Carc_info carc_info = dao.getCarc_info(info_seq);
		
		ModelAndView mav = new ModelAndView(viewerRoot + "carc_info");
		mav.addObject("carc_info", carc_info);
		return mav;
	}
	
	
	public ModelAndView getList_carc_info(HttpServletRequest req , HttpServletResponse res) {
		ApplicationContext ac = getApplicationContext();
		CarcDao___ dao = ac.getBean(CarcDao___.class);

		
		String addr_sido	= StringUtil.nvl   ( req.getParameter("addr_sido")    );
		String addr_gubun	= StringUtil.nvl   ( req.getParameter("addr_gubun")   );
		String addr_dong	= StringUtil.nvl   ( req.getParameter("addr_dong")    );
		String name			= StringUtil.nvl   ( req.getParameter("name")         );
		String order_col	= StringUtil.nvl   ( req.getParameter("order_col")    , "info_seq" );
		String order_method = StringUtil.nvl   ( req.getParameter("order_method") , "desc" );
		int    curpage      = StringUtil.nvlInt( req.getParameter("curpage")      );
		int    pageSize     = StringUtil.nvlInt( req.getParameter("pageSize")     );

		HashMap<String , Object> parameters = new HashMap<String, Object>();
		parameters.put("addr_sido", addr_sido);
		parameters.put("addr_gubun", addr_gubun);
		parameters.put("addr_dong", addr_dong);
		parameters.put("name", name);
		parameters.put("order_col", order_col);
		parameters.put("order_method", order_method);
		parameters.put("curpage", curpage);
		parameters.put("pageSize", pageSize);
		
		List<Carc_info> list = dao.getList_carc_info( parameters );
		
		ModelAndView mav = new ModelAndView(viewerRoot + "carc_list");
		mav.addObject("list_carc_info", list);
		
		return mav;
	}
	
	public ModelAndView goInsertCarc_info(HttpServletRequest req , HttpServletResponse res) {
		
		return new ModelAndView(viewerRoot + "carc_info_insert");
	}
	
	public ModelAndView insertCarc_info(HttpServletRequest req , HttpServletResponse res) {
		ApplicationContext ac = getApplicationContext();
		CarcDao___ dao = ac.getBean(CarcDao___.class);
		
		
		String addr_sido	= StringUtil.nvl   ( req.getParameter("addr_sido")    );
		String addr_gubun	= StringUtil.nvl   ( req.getParameter("addr_gubun")   );
		String addr_dong	= StringUtil.nvl   ( req.getParameter("addr_dong")    );
		String name			= StringUtil.nvl   ( req.getParameter("name")         );
		String description	= StringUtil.nvl   ( req.getParameter("description")  );
		
		HashMap<String , Object> parameters = new HashMap<String, Object>();
		parameters.put("addr_sido", addr_sido);
		parameters.put("addr_gubun", addr_gubun);
		parameters.put("addr_dong", addr_dong);
		parameters.put("name", name);
		parameters.put("description", description);
		
		int ret = dao.insertCarc_info(parameters);
		System.out.println("insertCarc_info res: "+ret);
		ModelAndView mav = new ModelAndView("redirect:/" + "carcenter.gcm?action=getList_carc_info");
		
		return mav;
	}*/
		
}